def run(params:list[str]):
    import sys
    from ApiBase import apiBase

    #pip install sacremoses
    #pip install jieba
    #pip install subword_nmt

    from modelscope.pipelines import pipeline
    from modelscope.utils.constant import Tasks
    from sklearn.feature_extraction.text import TfidfVectorizer
    from sklearn.metrics.pairwise import cosine_similarity

    #正向 问文本的分类, 可以反过来问(如中文翻译英文,反过来把英文翻译为中文,再和原始的中文做相似度比较),如果反过来检查不行,换一种问法,如果 文本属于这个分类吗?


    def similarity(text1,text2):
        if text1 is None or text2 is None:
            return 0
        if len(text1) ==0  or len(text2) ==0:
            return 0
        # 使用TF-IDF向量化文本
        vectorizer = TfidfVectorizer().fit_transform([text1, text2])
        # 计算余弦相似度
        cosine_sim = cosine_similarity(vectorizer[0:1], vectorizer[1:2])[0][0]
        return cosine_sim

    def damo_zh_en(input_sequence,sc1,trans2):
        pipeline_ch = pipeline(task=Tasks.translation, model="damo/nlp_csanmt_translation_zh2en")
        outputs = pipeline_ch(input=input_sequence)
        trans1=outputs['translation']
        #print("翻译1:"+trans1)
        #print("翻译2:"+trans2)

        pipeline_en = pipeline(task=Tasks.translation, model="damo/nlp_csanmt_translation_en2zh")
        outputs = pipeline_en(input=trans1)
        trans3=outputs['translation']
        #print("翻译3:"+trans3)
        if trans3==input_sequence:
            print(trans1)
            pipeline_en=None
            return 1
        sc2=similarity(input_sequence,trans3)
        if sc2 > sc1:
            print(trans1)
        else:
            print(trans2)
        pipeline_en=None

    def damo_en_zh(input_sequence,sc1,trans2):
        pipeline_ch = pipeline(task=Tasks.translation, model="damo/nlp_csanmt_translation_en2zh")
        outputs = pipeline_ch(input=input_sequence)
        trans1=outputs['translation']
        #print("翻译1:"+trans1)
        #print("翻译2:"+trans2)

        pipeline_en = pipeline(task=Tasks.translation, model="damo/nlp_csanmt_translation_zh2en")
        outputs = pipeline_en(input=trans1)
        trans3=outputs['translation']
        #print("翻译3:"+trans3)
        if trans3==input_sequence:
            print(trans1)
            pipeline_en=None
            return 1
        sc2=similarity(input_sequence,trans3)
        if sc2 > sc1:
            print(trans1)
        else:
            print(trans2)
        pipeline_en=None

    def llmch_zh_en(input_sequence):
        sys_prompt = "You are an expert in translating from Chinese to English"
        usr_prompt = f'''## Translation content
    {input_sequence}
    ## Requirement
    - Translate Chinese into English
    - Without any explanation, output the translated English structure directly
    #Output
    '''
        trans2=apiBase.llm_chat(sys_prompt,usr_prompt,"","")
        #print("翻译2:"+trans2)

        sys_prompt = "You are an expert in translating from English to Chinese"
        usr_prompt = f'''## Translation content
    {trans2}
    ## Requirement
    - Translate English into Chinese
    - Without any explanation, output the translated Chinese structure directly
    #Output
    '''
        trans4=apiBase.llm_chat(sys_prompt,usr_prompt,"","")
        #print("翻译4:"+trans4)
        if trans4==input_sequence:
            print(trans2)
            return (1,trans2)
        sc1 = similarity(input_sequence,trans4)    
        return ( sc1,trans2)

    def llmch_en_zh(input_sequence):
        sys_prompt = "You are an expert in translating from English to Chinese"
        usr_prompt = f'''## Translation content
    {input_sequence}
    ## Requirement
    - Translate English into Chinese
    - Without any explanation, output the translated Chinese structure directly
    #Output
    '''
        trans2=apiBase.llm_chat(sys_prompt,usr_prompt,"","")
        trans2=trans2.strip().replace("”","")
        
        #print("翻译2:"+trans2)

        sys_prompt = "You are an expert in translating from Chinese to English"
        usr_prompt = f'''## Translation content
    {trans2}
    ## Requirement
    - Translate Chinese into English
    - Without any explanation, output the translated English structure directly
    #Output
    '''
        trans4=apiBase.llm_chat(sys_prompt,usr_prompt,"","")
        trans4=trans2.strip().replace("”","")
        #print("翻译4:"+trans4)
        if trans4==input_sequence:
            print(trans2)
            return (1,trans2)
        sc1 = similarity(input_sequence,trans4)    
        return ( sc1,trans2)

    try:
        input_sequence = apiBase.argv(1,'每天都有好心情')
        zh =apiBase.argv(2,'zh')
        en =apiBase.argv(3,'en')
        print(f"zh={zh} {zh.find('zh')}")
        print(f"en={en} {en.find('en')}")
        #input_sequence = '每天都有好心情'
        if zh.find('zh')!=-1  and en.find('en')!=-1:
            sc1,trans2=llmch_zh_en(input_sequence)
            if sc1 < 1:
                damo_zh_en(input_sequence,sc1,trans2)
                
        if zh.find('en')!=-1  and en.find('zh')!=-1:
            sc1,trans2=llmch_en_zh(input_sequence)
            if sc1 < 1:
                damo_en_zh(input_sequence,sc1,trans2)
    finally:
        pipeline_t2t=None   